﻿//------------------------------------------------------------------------------
// <copyright file="CSSqlFunction.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;

public partial class UserDefinedFunctions
{
    [Microsoft.SqlServer.Server.SqlFunction]
    public static SqlInt64 Hash64(SqlString str)
    {
        ulong hashedValue = 3074457345618258791ul;
        for (int i = 0; i < str.Value.Length; i++)
        {
            hashedValue += str.Value[i];
            hashedValue *= 3074457345618258799ul;
        }
        return new SqlInt64((long)hashedValue);
    }
}
